package com.wsd.music.utils;

import com.alibaba.fastjson.JSONObject;

public final class Message {

    private JSONObject jsonObject;
    private static String success = "1";
    private static String error = "0";

    private Message() {
        this.jsonObject = new JSONObject();
    }
    private Message(String code, String message) {
        this();
        this.jsonObject.put(Const.CODE, code);
        this.jsonObject.put(Const.MSG, message);
    }
    private Message(String code, String message, String username) {
        this();
        this.jsonObject.put(Const.CODE, code);
        this.jsonObject.put(Const.MSG, message);
        this.jsonObject.put(Const.NAME, username);
    }

    public static JSONObject simpleMessage(String code, String message) {
        return new Message(code, message).getJsonObject();
    }

    public static JSONObject success(String message) {
        return Message.simpleMessage(success, message);
    }

    public static JSONObject error(String message) {
        return Message.simpleMessage(error, message);
    }

    public static JSONObject message(String code, String message, String username) {
        return new Message(code, message, username).getJsonObject();
    }

    public JSONObject getJsonObject() {
        return jsonObject;
    }
    public void setJsonObject(JSONObject jsonObject) {
        this.jsonObject = jsonObject;
    }
}
